﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using log4net;
using System.Reflection;

namespace AnyOffice.general.vehicle
{
    public partial class vehicle_detail :ModulePage
    {

        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

     
        protected void Page_Load(object sender, EventArgs e)
        {
            int vehicleId = (Request.QueryString["vehicle_id"] != null) ? int.Parse(Request.QueryString["vehicle_id"]) : 0;
            DataTable table = new VehicleDao().SelectByVehicleId(base.Conn, vehicleId);
            if (table.Rows.Count == 0)
            {
                this.pnlMain.Visible = false;
                this.litMessage.Text = base.ShowErrorClose("无车辆信息");
            }
            else
            {
                this.litNumber.Text = (table.Rows[0]["Number"] != DBNull.Value) ? table.Rows[0]["Number"].ToString() : "";
                if (table.Rows[0]["Photo"] != DBNull.Value)
                {
                    this.litPhoto.Text = "<a href=\"photo.aspx?vehicle_id=" + vehicleId.ToString() + "\" target=\"_blank\" title=\"点击查看放大图片\"><img src=\"photo.aspx?vehicle_id=" + vehicleId.ToString() + "\" width=\"160\" height=\"160\" border=\"0\"></a>";
                }
                this.litModel.Text = (table.Rows[0]["Model"] != DBNull.Value) ? table.Rows[0]["Model"].ToString() : "";
                this.litEngineNum.Text = (table.Rows[0]["EngineNum"] != DBNull.Value) ? table.Rows[0]["EngineNum"].ToString() : "";
                this.litType.Text = (table.Rows[0]["Type"] != DBNull.Value) ? table.Rows[0]["Type"].ToString() : "";
                this.litDriver.Text = (table.Rows[0]["Driver"] != DBNull.Value) ? table.Rows[0]["Driver"].ToString() : "";
                this.litPrice.Text = (table.Rows[0]["Price"] != DBNull.Value) ? table.Rows[0]["Price"].ToString() : "";
                this.litBuyDate.Text = (table.Rows[0]["BuyDate"] != DBNull.Value) ? Convert.ToDateTime(table.Rows[0]["BuyDate"].ToString()).ToString("yyyy-MM-dd") : "";
                this.litStatus.Text = (table.Rows[0]["Status"] != DBNull.Value) ? table.Rows[0]["Status"].ToString() : "";
                string str = (table.Rows[0]["Remark"] != DBNull.Value) ? table.Rows[0]["Remark"].ToString() : "";
                str = str.Replace("\r\n", "<br>");
                this.litRemark.Text = str;
            }
        } 

    }
}
